#include "PhysXWrappers.h"

namespace FinalRendering
{
	namespace Engine
	{
		namespace Physics
		{
			StreamWrapper::StreamWrapper(Stream *stream)
			{
				s = stream;
			}

			NxU8 StreamWrapper::readByte() const
			{
				NxU8 rs;
				s->ReadBuffer(&rs,1);
				return rs;
			}
			
			NxU16 StreamWrapper::readWord() const
			{
				NxU16 rs;
				s->ReadBuffer(&rs, 1);
				return rs;
			}

			NxU32 StreamWrapper::readDword() const
			{
				NxU32 rs;
				s->ReadBuffer(&rs, 1);
				return rs;
			}

			NxF64 StreamWrapper::readDouble() const
			{
				NxF64 rs;
				s->ReadBuffer(&rs,1);
				return rs;
			}

			NxF32 StreamWrapper::readFloat() const
			{
				NxF32 rs;
				s->ReadBuffer(&rs,1);
				return rs;
			}

			void StreamWrapper::readBuffer(void * buffer, NxU32 size) const
			{
				s->ReadBuffer(buffer, 1, size);
			}

			NxStream& StreamWrapper::storeByte(NxU8 b)
			{
				s->WriteBuffer(&b,1);
				return *this;
			}

			NxStream& StreamWrapper::storeWord(NxU16 w)
			{
				s->WriteBuffer(&w,1);
				return *this;
			}

			NxStream& StreamWrapper::storeDword(NxU32 d)
			{
				s->WriteBuffer(&d,1);
				return *this;
			}

			NxStream& StreamWrapper::storeFloat(NxF32 f)
			{
				s->WriteBuffer(&f,1);
				return *this;
			}

			NxStream& StreamWrapper::storeDouble(NxF64 f)
			{
				s->WriteBuffer(&f,1);
				return *this;
			}
			
			NxStream& StreamWrapper::storeBuffer(const void *buffer, NxU32 size)
			{
				s->WriteBuffer(buffer,1,size);
				return *this;
			}


		}
	}
}